//
// Created by zxh on 2020-4-28.
//

#include "common.h"
#include <stdio.h>

#if DEBUG_STRING_PRINTF_SWITCH_ENABLE == 0x01
void CharArrayToHexString(char* pOut, const char* pInput, const int nInLen)
{
    const char* chHexList = "0123456789ABCDEF";
    int nIndex = 0;
    int i=0, j=0;

    for (i=0, j=0;i<nInLen;i++, j+=2)
    {
        nIndex = pInput[i] & 0xf;
        pOut[i*2+1] = chHexList[nIndex];
        nIndex = ((pInput[i]>>4) & 0xf);
        pOut[i*2] = chHexList[nIndex];
    }
}

void LogOutHexString(char* data,int len)
{
    int strlen = 2 * len + 1;
    char *STR = (char *)malloc(sizeof(char ) *strlen);

    memset(STR,0,strlen);
    CharArrayToHexString(STR,data,len);

    LOGD("%s", STR);
    free(STR);
}
#else
void CharArrayToHexString(char* pOut, const char* pInput, const int nInLen)
{
}

void LogOutHexString(char* data,int len)
{
}
#endif
